from tests.rypark_background.get_cookie import *
from common.config import *
import requests


class Member:
    # =====================大运营后台=====================
    # status:0：解绑中，1：绑定中
    # 运营后台查询用户绑定数据
    def internal_member_list(self, env, bindTimeEnd=None, bindTimeStart=None,
                             cardNumber=None, parkName=None, phone=None,
                             status=None, unbindTimeStart=None, unbindTimeEnd=None):
        base_url = getconf(env, "rypark_url")
        url = base_url + "easypark-backend/parkMember/memberInfoList"
        headers = {"content-type": "application/json;charset=UTF-8",
                   "cookie": internal_cookies(env)}
        dict = {"bindTimeEnd": bindTimeEnd,
                "bindTimeStart": bindTimeStart,
                "cardNumber": cardNumber,
                "parkName": parkName,
                "phone": phone,
                "status": status,
                "unbindTimeStart": unbindTimeStart,
                "unbindTimeEnd": unbindTimeEnd}
        return requests.post(url, headers=headers, json=dict).json()

    # 运营后台导出用户绑定数据
    def internal_member_export(self, env, bindTimeEnd=None, bindTimeStart=None,
                               cardNumber=None, parkName=None, phone=None,
                               status=None, unbindTimeStart=None, unbindTimeEnd=None):
        base_url = getconf(env, "rypark_url")
        url = base_url + "easypark-backend/parkMember/memberInfoListExport"
        headers = {"content-type": "application/json;charset=UTF-8",
                   "cookie": internal_cookies(env)}
        dict = {"bindTimeEnd": bindTimeEnd,
                "bindTimeStart": bindTimeStart,
                "cardNumber": cardNumber,
                "parkName": parkName,
                "phone": phone,
                "status": status,
                "unbindTimeStart": unbindTimeStart,
                "unbindTimeEnd": unbindTimeEnd}
        return requests.post(url, headers=headers, json=dict).json()

    # =====================商户后台=====================
    # status:0：解绑中，1：绑定中
    # 商户后台查询用户绑定数据
    def shop_member_list(self, env, bindTimeEnd=None, bindTimeStart=None,
                         cardNumber=None, parkName=None, phone=None,
                         status=None, unbindTimeStart=None, unbindTimeEnd=None):
        base_url = getconf(env, "rypark_url")
        url = base_url + "easypark-backend/parkMember/bizMemberInfoList"
        headers = {"content-type": "application/json;charset=UTF-8",
                   "cookie": shop_cookies(env)}
        dict = {"bindTimeEnd": bindTimeEnd,
                "bindTimeStart": bindTimeStart,
                "cardNumber": cardNumber,
                "parkName": parkName,
                "phone": phone,
                "status": status,
                "unbindTimeStart": unbindTimeStart,
                "unbindTimeEnd": unbindTimeEnd}
        return requests.post(url, headers=headers, json=dict).json()

    # 商户后台导出用户绑定数据
    def shop_member_export(self, env, bindTimeEnd=None, bindTimeStart=None,
                           cardNumber=None, parkName=None, phone=None,
                           status=None, unbindTimeStart=None, unbindTimeEnd=None):
        base_url = getconf(env, "rypark_url")
        url = base_url + "easypark-backend/parkMember/bizMemberInfoListExport"
        headers = {"content-type": "application/json;charset=UTF-8",
                   "cookie": shop_cookies(env)}
        dict = {"bindTimeEnd": bindTimeEnd,
                "bindTimeStart": bindTimeStart,
                "cardNumber": cardNumber,
                "parkName": parkName,
                "phone": phone,
                "status": status,
                "unbindTimeStart": unbindTimeStart,
                "unbindTimeEnd": unbindTimeEnd}
        return requests.post(url, headers=headers, json=dict).json()
